package practice_03;

import java.util.Scanner;

public class ChangeM {
    //    金额转换
//    输入：一个金额（1-9999999）
//    输出：大写
    public static void changeM() {
        Scanner sc = new Scanner(System.in);
        String[] Big = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖", "拾"};
        String[] BigP = {"圆", "拾", "佰", "仟", "万", "拾", "佰"};
        int money;
        System.out.print("请输入要转换的金额:");
        while (true) {
            money = sc.nextInt();
            if (money >= 1 && money <= 9999999) {
                break;
            }
            System.out.print("请输入有效的金额！:");
        }
        String Sm = "";
        while (money > 0) {
            int x = money % 10;
            Sm = Big[x] + Sm;
            money /= 10;
        }
        String newSm = "";
        for (int i = 0, j = Sm.length() - 1; i < Sm.length(); i++, j--) {
            newSm += Sm.charAt(i) + BigP[j];
        }
        System.out.println("转换后的金额:" + newSm);
    }
}
